<template>
  <div id="app">
    <Header notab=""/>
    <div class="contentWeb">
      <div style="background: #fff; padding: 40px; margin-top: 30px;">
        <h2 style="margin-bottom: 45px;">企业注册</h2>
        <el-form ref="form" :model="form" :rules="rules" label-width="180px" style="margin-top: 20px;">
          <el-form-item label="用户名" prop="account">
            <el-input placeholder="请输入" v-model="form.account" style="width: 600px"/>
            <span class="tishiy">6-16位英文或数字</span>
          </el-form-item>
          <el-form-item label="密码" prop="password">
            <el-input type="password" placeholder="请输入" v-model="form.password" style="width: 600px"/>
            <span class="tishiy">6-16位字母与数字组合</span>
          </el-form-item>
          <el-form-item label="重复密码" required>
            <el-input type="password" placeholder="请输入" v-model="password2" style="width: 600px"/>
            <span class="tishiy" style="color: red">{{ passtext }}</span>
          </el-form-item>
          <el-form-item label="企业全称" prop="name">
            <el-input placeholder="请输入" v-model="form.name" style="width: 600px"/>
            <span class="tishiy">请确保填写信息真实有效</span>
          </el-form-item>
          <el-form-item label="统一社会信用代码" prop="sociologyCreditCode">
            <el-input placeholder="请输入" v-model="form.sociologyCreditCode" style="width: 600px"/>
            <span class="tishiy">请确保填写信息真实有效</span>
          </el-form-item>
          <el-form-item label="企业简称" prop="nickname">
            <el-input placeholder="请输入" maxlength="4" v-model="form.nickname" style="width: 600px"/>
            <span class="tishiy">不超过4个汉字</span>
          </el-form-item>
          <el-form-item label="企业Logo" prop="logo">
            <div class="uploadimg" >
              <el-upload
                v-loading="logoLoading"
                name="enterprise_licence"
                class="avatar-uploader"
                :action="uploadLicence"
                :show-file-list="false"
                :on-success="logoSuccess"
                accept=".jpg,.png"
                :before-upload="beforeLogoUpload">
                <img
                  v-if="form.logo"
                  :src="form.logo"
                  class="avatar"
                  :style="uplaodstyle">
                <i v-else class="el-icon-plus avatar-uploader-icon" :style="uplaodstyle"></i>
                <div slot="tip" class="el-upload__tip">支持格式：jpg、png
                </div>
              </el-upload>
            </div>
          </el-form-item>
          <el-form-item label="经办人身份证明" prop="jbrsfzm">
            <div class="uploadimg" >
              <el-upload
                v-loading="jbrLoading"
                name="enterprise_licence"
                class="avatar-uploader"
                :action="uploadLicence"
                :show-file-list="false"
                :on-success="jbrSuccess"
                accept=".jpg,.png"
                :before-upload="beforeJBRUpload">
                <img
                  v-if="form.jbrsfzm"
                  :src="form.jbrsfzm"
                  class="avatar"
                  :style="uplaodstyle">
                <i v-else class="el-icon-plus avatar-uploader-icon" :style="uplaodstyle"></i>
                <div slot="tip" class="el-upload__tip">支持格式：jpg、png
                </div>
              </el-upload>
            </div>
            <span class="tishiy">本企业和东港人社网后台系统可见</span>
          </el-form-item>
          <el-form-item label="用人单位委托证明" prop="yrdwwtzm">
            <div class="uploadimg" >
              <el-upload
                v-loading="wtzmLoading"
                name="enterprise_licence"
                class="avatar-uploader"
                :action="uploadLicence"
                :show-file-list="false"
                :on-success="wtzmSuccess"
                accept=".jpg,.png"
                :before-upload="beforeWTZMUpload">
                <img
                  v-if="form.yrdwwtzm"
                  :src="form.yrdwwtzm"
                  class="avatar"
                  :style="uplaodstyle">
                <i v-else class="el-icon-plus avatar-uploader-icon" :style="uplaodstyle"></i>
                <div slot="tip" class="el-upload__tip">支持格式：jpg、png
                </div>
              </el-upload>
            </div>
            <span class="tishiy">本企业和东港人社网后台系统可见</span>
          </el-form-item>
          <el-form-item label="营业执照" prop="businessLicenseUrl">
            <div class="uploadimg" >
              <el-upload
                v-loading="licenseLoading"
                name="enterprise_licence"
                class="avatar-uploader"
                :action="uploadLicence"
                :show-file-list="false"
                :on-success="licenceSuccess"
                accept=".jpg,.png"
                :before-upload="beforeLicenseUpload">
                <img
                  v-if="form.businessLicenseUrl"
                  :src="form.businessLicenseUrl"
                  class="avatar"
                  :style="uplaodstyle">
                <i v-else class="el-icon-plus avatar-uploader-icon" :style="uplaodstyle"></i>
                <div slot="tip" class="el-upload__tip">支持格式：jpg、png  </div>
              </el-upload>
            </div>
            <span class="tishiy">本企业和东港人社网后台系统可见</span>
          </el-form-item>
          <el-form-item label="企业法人身份证" prop="idCard">
            <div class="uploadimg" >
              <el-upload
                v-loading="frontLoading"
                name="enterprise_licence"
                class="avatar-uploader"
                :action="uploadLicence"
                :show-file-list="false"
                :on-success="frontSuccess"
                accept=".jpg,.png"
                :before-upload="beforeFrontUpload">
                <img
                  v-if="form.sfzZm"
                  :src="form.sfzZm"
                  class="avatar"
                  :style="uplaodstyle">
                <i v-else class="el-icon-plus avatar-uploader-icon" :style="uplaodstyle"></i>
                <div slot="tip" class="el-upload__tip">支持格式：jpg、png
                  <span class="mark">正面</span>
                </div>
              </el-upload>
            </div>
            <div class="uploadimg" >
              <el-upload
                v-loading="backLoading"
                name="enterprise_licence"
                class="avatar-uploader"
                :action="uploadLicence"
                :show-file-list="false"
                :on-success="backSuccess"
                accept=".jpg,.png"
                :before-upload="beforeBackUpload">
                <img
                  v-if="form.sfzFm"
                  :src="form.sfzFm"
                  class="avatar"
                  :style="uplaodstyle">
                <i v-else class="el-icon-plus avatar-uploader-icon" :style="uplaodstyle"></i>
                <div slot="tip" class="el-upload__tip">
                  <span class="mark" style="bottom:-14px" >反面</span>
                </div>
              </el-upload>
            </div>
            <span class="tishiy">本企业和东港人社网后台系统可见</span>
          </el-form-item>
          <el-form-item required label="企业性质" prop="enterpriseNature">
            <el-select v-model="form.enterpriseNature" :loading="xingzhiloading" placeholder="公司性质">
              <el-option
                :label="item.subTypeName"
                :key="index"
                :value="item.subTypeName"
                v-for="(item, index) in xingzhiList"></el-option>

            </el-select>
          </el-form-item>
          <el-form-item required label="企业规模" prop="companySize">
            <el-select v-model="form.companySize" :loading="guimoloading" placeholder="公司规模">
              <el-option
                :label="item.subTypeName"
                :key="index"
                :value="item.subTypeName"
                v-for="(item, index) in guimoList"></el-option>

            </el-select>
          </el-form-item>
          <el-form-item required label="所属行业">
            <div>
              <el-tag
                style="margin-right: 10px;"
                v-for="(item, index) in industry"
                @close="delIndustry(index)"
                :key="index"
                closable
                :disable-transitions="false" >
                {{ item }}
              </el-tag>
            </div>
            <el-cascader
              v-show="industry.length < 5"
              style="width: 200px"
              :options="hangyelist"
              @change="hangyechange"
              placeholder="请选择行业"
              v-model="industrysel"
              clearable
              :show-all-levels="false"
              :props="{value: 'name', label: 'name', children: 'contentSet'}"></el-cascader>
          </el-form-item>

          <el-form-item label="企业所在地" prop="addressDetail">
            <!--address_detail-->
            <Area
              :hidequ="false"
              :form="{province: form.province, city: form.city,district: form.district}"
              @addresschange="addresschange"/>
            <el-input placeholder="请输入详细地址" v-model="form.addressDetail" style="width: 400px"/>
          </el-form-item>
          <el-form-item label="招聘联系人" prop="contacts">
            <el-input placeholder="请输入" v-model="form.contacts" style="width: 400px"/>
          </el-form-item>
          <el-form-item label="身份证号" prop="identifyCode">
            <el-input placeholder="请输入" v-model="form.identifyCode" style="width: 400px"/>
          </el-form-item>
          <el-form-item label="手机号" prop="mobileNum">
            <el-input placeholder="请输入" v-model="form.mobileNum" style="width: 400px"/>
          </el-form-item>
          <el-form-item prop="verifyCode" style="margin-top: 10px;" >
            <el-input
              placeholder="验证码"
              v-model="form.verifyCode"
              maxlength="6"
              style="width: 220px; margin-right: 20px; display: inline-block; float: left;"></el-input>
            <el-button
              :disabled="sendCode > 0 ? true: false"
              @click="sendSms"
              style="width: 150px;height:32px;line-height:10px; margin-top:4px"
              type="primary">{{ sendCode ?
                sendCode+'秒后可再次获取' : '点击获取验证码' }}
            </el-button>
            <!-- <div class="yzms"></div> -->
          </el-form-item>
          <el-form-item label="电子邮件" prop="email">
            <el-input placeholder="请输入" v-model="form.email" style="width: 400px"/>
          </el-form-item>
          <el-form-item label="企业介绍" prop="introduction">
            <el-input type="textarea" rows="6" v-model="form.introduction" style="width: 70%;"></el-input>
          </el-form-item>
          <el-form-item required label="工作时间">
            <el-time-picker
              is-range
              v-model="value1"
              range-separator="至"
              start-placeholder="开始时间"
              end-placeholder="结束时间"
              placeholder="选择时间范围">
            </el-time-picker>
          </el-form-item>
          <el-form-item label="企业福利">
            <el-tag
              :key="tag"
              v-for="tag in fuli"
              closable
              :disable-transitions="false"
              @close="handleClose(tag)">
              {{ tag }}
            </el-tag>
            <el-input
              v-if="inputVisible"
              class="input-new-tag"
              v-model="inputValue"
              ref="saveTagInput"
              size="small"
              @keyup.enter.native="handleInputConfirm"
              @blur="handleInputConfirm"
            >
            </el-input>
            <el-button v-else class="button-new-tag" size="small" @click="showInput">+ 添加新的</el-button>
            <el-button type="primary" style="margin-left: 30px;" size="small" @click="getTreatmentState">重置
            </el-button>
          </el-form-item>
          <el-form-item style="margin-top: 60px">
            <el-button
              style="background: #20a2b2; width: 300px; border: 0; margin-left: 150px;"
              type="primary"
              @click="onSubmit('form')">注册
            </el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <Footer/>
  </div>
</template>
<script type="text/babel">
// @ is an alias to /src
import util from '../../assets/js/util'
import Header from '../../components/header'
import Footer from '../../components/footer'
import Area from '../../components/area'
import moment from 'moment'

import {
  Companyregister,
  // CompanyRegisterUpdate,
  EnterpriseInfo,
  OccupationType,
  EnterpriseNature,
  EnterpriseSize,
  updateEnterpriseInfo,
  uploadLicence,
  sendMessage,
  GetUrlParam,
  TreatmentState
} from '../../assets/js/domains'

// approval 1:待审核，2: 审核通过，3：审核没通过
// user_type 用户种类，1：企业，2：个人, 3:微信小程序
export default {
  name: 'Company',
  components: {
    Header,
    Footer,
    Area
  },
  directives: {},
  data: function () {
    return {
      industrysel: [],
      industry: [],
      euid: '',
      rules: {
        contacts: [
          { required: true, message: '请输入联系人', trigger: 'blur' },
          { validator: this.validSensWords, trigger: 'blur' }
        ],
        introduction: [
          { required: true, message: '请输入企业描述', trigger: 'blur' },
          { validator: this.validSensWords, trigger: 'blur' }
        ],
        email: [
          { required: true, message: '请输入电子邮箱', trigger: 'blur' },
          { validator: this.emailchange, trigger: 'blur' }
        ],
        addressDetail: [
          { required: true, message: '请输入详细地址', trigger: 'blur' },
          { validator: this.validSensWords, trigger: 'blur' }
        ],
        account: [
          { required: true, message: '请输入用户名称', trigger: 'blur' },
          { validator: this.checkname, trigger: 'blur' },
          { validator: this.validSensWords, trigger: 'blur' }
        ],
        sociologyCreditCode: [
          { required: true, message: '请输入社会统一信用代码', trigger: 'blur' },
          { validator: this.validSensWords, trigger: 'blur' }
        ],
        name: [
          { required: true, message: '请输入企业全称', trigger: 'blur' },
          { validator: this.validSensWords, trigger: 'blur' }
        ],
        nickname: [
          { required: true, message: '请输入企业简称', trigger: 'blur' },
          { validator: this.checknickname, trigger: 'blur' },
          { validator: this.validSensWords, trigger: 'blur' }
        ],
        verifyCode: [
          { required: true, message: '请输入验证码', trigger: 'blur' }
        ],
        logo: [
          { required: true, message: '请上传企业logo', trigger: 'change' }
        ],
        jbrsfzm: [
          { required: true, message: '请上传经办人身份证明', trigger: 'change' }
        ],
        yrdwwtzm: [
          { required: true, message: '请上传用人单位委托证明', trigger: 'change' }
        ],
        businessLicenseUrl: [
          { required: true, message: '请上传营业执照', trigger: 'change' }
        ],
        idCard: [
          { required: true, validator: this.checkIdCard, trigger: 'blur' }
        ],
        enterpriseNature: [
          { required: true, message: '请选择企业性质', trigger: 'change' }
        ],
        companySize: [
          { required: true, message: '请选择企业规模', trigger: 'change' }
        ],
        // industrysel: [
        //   { required: true, message: '请选择所属行业', trigger: 'change' }
        // ],
        identifyCode: [
          { required: true, message: '请输入身份证号', trigger: 'blur' },
          { validator: this.checkcard, trigger: 'blur' }
        ],
        mobileNum: [
          { required: true, message: '请输入手机号', trigger: 'blur' },
          { validator: this.phonechange, trigger: 'blur' }
        ],
        password: [
          { required: true, message: '请输入密码', trigger: 'blur' },
          { validator: this.validatePass, trigger: 'blur' }
        ]
      },
      logoLoading: false,
      licenseLoading: false,
      frontLoading: false,
      backLoading: false,
      jbrLoading: false,
      wtzmLoading: false,
      uploadLicence: uploadLicence,
      xingzhiloading: true,
      guimoloading: true,
      hangyeLoading: true,
      xingzhiList: [],
      hangyelist: [],
      guimoList: [],
      uplaodstyle: {
        width: '160px',
        height: '160px'
      },
      password2: '',
      form: {
        positionSet: [
        ],
        province: '',
        city: '',
        district: '',
        addressDetail: '',
        businessLicenseUrl: ''
      },
      fuli: [],
      passtext: '',
      value: '',
      dynamicTags: [],
      inputVisible: false,
      sendCode: 0,
      smsCode: '',
      inputValue: '',
      // address: '', // 详细地址
      value1: [new Date(2016, 9, 10, 8, 30), new Date(2016, 9, 10, 17, 30)]
    }
  },
  created () {
    document.title = '企业注册'
  },
  computed: {},
  mounted () {
    this.euid = GetUrlParam('euid')
    this.getTreatmentState()
    this.getOccupationType()
    this.getEnterpriseNature()
    this.getEnterpriseSize()
    if (this.euid) {
      this.getEnterpriseInfo()
    }
  },
  methods: {
    delIndustry: function (index) {
      this.industry.splice(index, 1)
    },
    hangyechange: function (e) {
      if (this.industry.indexOf(e) < 0) {
        this.industry.push(e[1])
      }
      this.industrysel = []
    },
    // 选择器
    handleClose: function (tag) {
      if (this.fuli.length === 1) {
        return false
      }
      this.fuli.splice(this.fuli.indexOf(tag), 1)
    },
    getEnterpriseInfo: function () {
      EnterpriseInfo({ enterprise_id: this.euid }).then(res => {
        if (res.code === 200) {
          delete res.data.password
          this.form = res.data
          this.form.province = res.data.province.split(',')[0] // 兼容后台代码
          // this.address = res.data.addressDetail
          this.industry = res.data.industry.split(',').filter(item => !!item.trim())

          res.data.treatment && (this.fuli = res.data.treatment.split(',').filter(item => !!item.trim()))
        }
      })
    },
    showInput: function () {
      this.inputVisible = true
      const _this = this
      this.$nextTick(function () {
        _this.$refs.saveTagInput.$refs.input.focus()
      })
    },

    handleInputConfirm () {
      this.validSensWords(null, this.inputValue, valid => {
        if (valid) {
          this.$alert(valid)
          return
        }
        this.inputValue && this.fuli.push(this.inputValue)
        this.inputVisible = false
        this.inputValue = ''
      })
    },
    getTreatmentState: function () {
      const _this = this
      TreatmentState().then(function (res) {
        if (res.code === 200) {
          _this.fuli = []
          for (let i = 0; i < res.data.length; i++) {
            _this.fuli.push(res.data[i].subTypeName)
          }
        }
      })
    },
    checkname: function (rule, value, callback) {
      if (value === '') {
        callback(new Error('请输入用户名称'))
      } else {
        var myreg = '^[0-9a-zA-Z]{6,12}$'
        var re = new RegExp(myreg)
        if (!re.test(value)) {
          callback(new Error('请输入6-16位英文或数字'))
        } else {
          callback()
        }
      }
    },
    validatePass: function (rule, value, callback) {
      if (value === '') {
        callback(new Error('请输入密码'))
      } else {
        var myreg = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/
        var re = new RegExp(myreg)
        if (!re.test(value)) {
          callback(new Error('请输入6-16位英文与数字组合'))
        } else {
          callback()
        }
      }
    },
    checknickname: function (rule, value, callback) {
      if (value === '') {
        callback(new Error('请输入企业简称'))
      } else {
        var myreg = /^[\u4e00-\u9fa5]+$/
        var re = new RegExp(myreg)
        if (!re.test(value)) {
          callback(new Error('请输入汉字'))
        } else {
          callback()
        }
      }
    },
    checkIdCard: function (rule, value, callback) {
      if (!this.form.sfzZm) {
        return callback(new Error('请上传法人身份证正面照'))
      }
      if (!this.form.sfzFm) {
        return callback(new Error('请上传法人身份证反面照'))
      }
      callback()
    },
    checkcard: function (rule, value, callback) {
      if (!util.isIdCode(value)) {
        return callback(new Error('请输入正确的身份证号'))
      }
      callback()
    },

    phonechange: function (rule, value, callback) {
      if (value === '') {
        callback(new Error('请输入手机号码'))
      } else {
        var myreg = /^1(3|4|5|6|7|8|9)\d{9}$/
        var re = new RegExp(myreg)
        if (!re.test(value)) {
          callback(new Error('手机号格式错误'))
        } else {
          callback()
        }
      }
    },

    emailchange: function (rule, value, callback) {
      if (value === '') {
        callback(new Error('请输入电子邮箱'))
      } else {
        var myreg = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,4}$/
        var re = new RegExp(myreg)
        if (!re.test(value)) {
          callback(new Error('电子邮箱格式错误'))
        } else {
          callback()
        }
      }
    },

    addresschange: function (e) {
      if (e.districtName) {
        this.form.province = e.province
        this.form.city = e.city
        this.form.district = e.district
        this.form.addressDetail = e.province.split('|')[1] + e.city.split('|')[1] + e.district.split('|')[1]
      }
    },
    logoSuccess: function (e) {
      const _this = this
      this.logoLoading = false
      if (e.code === 200) {
        _this.form.logo = e.data
        _this.form = Object.assign({}, _this.form)
      }
    },
    licenceSuccess (e) {
      const _this = this
      this.licenseLoading = false
      if (e.code === 200) {
        _this.form.businessLicenseUrl = e.data
        _this.form = Object.assign({}, _this.form)
      }
    },
    handleAvatarSuccess (e) {
      const _this = this
      this.loading = false
      if (e.code === 200) {
        _this.form.logoUrl = e.data
        _this.form = Object.assign({}, _this.form)
      }
    },
    jbrSuccess (e) {
      this.jbrLoading = false
      if (e.code === 200) {
        this.form.jbrsfzm = e.data
      }
    },
    wtzmSuccess (e) {
      this.wtzmLoading = false
      if (e.code === 200) {
        this.form.yrdwwtzm = e.data
      }
    },
    frontSuccess (e) {
      this.frontLoading = false
      if (e.code === 200) {
        this.form.sfzZm = e.data
      }
    },
    backSuccess (e) {
      this.backLoading = false
      if (e.code === 200) {
        this.form.sfzFm = e.data
      }
    },
    beforeLogoUpload (file) {
      return this.beforeUpload(file, 'logo')
    },
    beforeJBRUpload (file) {
      this.beforeUpload(file, 'jbr')
    },
    beforeWTZMUpload (file) {
      return this.beforeUpload(file, 'wtzm')
    },
    beforeFrontUpload (file) {
      return this.beforeUpload(file, 'front')
    },
    beforeBackUpload (file) {
      return this.beforeUpload(file, 'back')
    },
    beforeLicenseUpload (file) {
      return this.beforeUpload(file, 'license')
    },
    beforeContentSetUpload (file) {
      return this.beforeUpload(file, 'contentSet')
    },
    beforeUpload: function (file, type) {
      const suffix = file.name.substr(file.name.lastIndexOf('.') + 1)
      if (!['jpg', 'png'].includes(suffix.toLowerCase())) {
        this.$message.error('只能上传 jpg或png 格式的图片!')
        return false
      }
      this[type + 'Loading'] = true
      return true
    },

    getOccupationType: function () {
      const _this = this
      OccupationType().then(function (res) {
        _this.hangyeLoading = false
        if (res.code === 200) {
          _this.hangyelist = res.data
        } else {
          _this.$alert(res.msg, '提示', {
            confirmButtonText: '确定',
            callback: function () {
            }
          })
        }
      })
    },
    getEnterpriseNature: function () {
      const _this = this
      EnterpriseNature().then(function (res) {
        _this.xingzhiloading = false
        if (res.code === 200) {
          _this.xingzhiList = res.data
        } else {
          _this.$alert(res.msg, '提示', {
            confirmButtonText: '确定',
            callback: function () {
            }
          })
        }
      })
    },
    getEnterpriseSize: function () {
      const _this = this
      EnterpriseSize().then(function (res) {
        _this.guimoloading = false
        if (res.code === 200) {
          _this.guimoList = res.data
        } else {
          _this.$alert(res.msg, '提示', {
            confirmButtonText: '确定',
            callback: function () {
            }
          })
        }
      })
    },

    // 验证码
    sendSms: function () {
      var _this = this
      sendMessage({ phoneNumber: this.form.mobileNum }).then(function (res) {
        if (res.code === 200) {
          _this.$message.success('验证码发送成功')
          _this.sendCodeInterval()
          _this.smsCode = res.data
        }
      })
    },

    sendCodeInterval: function () {
      this.sendCode = 60
      var _this = this
      var intervalHanlder = setInterval(function () {
        _this.sendCode -= 1
        if (_this.sendCode <= 0) {
          clearInterval(intervalHanlder)
        }
      }, 1000)
    },

    onSubmit (form) {
      const _this = this
      this.$refs[form].validate(function (valid) {
        if (valid) {
          if (_this.form.password !== _this.password2) {
            _this.passtext = '密码不一致，请重新输入'
            _this.$message.error('密码不一致，请重新输入')
            return false
          }

          if (_this.form.province === '' || _this.form.city === '' || _this.form.distric === '') {
            _this.$message.error('请完善省市区信息')
            return false
          }

          if (_this.fuli.length < 1 || _this.fuli.length > 15) {
            _this.$message.error('企业福利数量为1~15个')
            return false
          }
          if (_this.industry.length === 0) {
            _this.$message.error('请选择所属行业')
            return false
          }
          if (_this.industry.length > 5) {
            _this.$message.error('所属行业不能超过5个')
            return false
          }

          // todo
          if (!_this.form.verifyCode || _this.form.verifyCode !== _this.smsCode) {
            _this.$message.error('短信验证码输入不正确')
            return false
          }

          _this.form.treatment = _this.fuli.join(',')
          _this.form.startWorkTime = moment(_this.value1[0]).format('HH:mm')
          _this.form.endWorkTime = moment(_this.value1[1]).format('HH:mm')
          _this.form.industry = _this.industry.filter(item => !!item).join(',')
          let form = Object.assign({}, _this.form)
          // form.addressDetail = _this.address + _this.form.addressDetail

          form.password = util.strEncode(form.password)
          form.approval = 1
          let registerFn = Companyregister
          if (_this.euid) {
            // registerFn = CompanyRegisterUpdate
            registerFn = updateEnterpriseInfo
            delete form.createTime
            delete form.updateTime
            delete form.contentSet
            delete form.positionSet
            delete form.enterpriseInfo

            form = Object.assign({}, form, {
              ep_uid: form.enterprise_id,
              smsCode: form.verifyCode
              // approvalResultInfo: '', // 审核失败结果
              // locked: 1, // 1启用  2禁用 是否要更新
            })
            for (const key in form) {
              if (form[key] == null) {
                form[key] = ''
              }
            }
          }

          registerFn(form).then(function (res) {
            if (res.code === 200) {
              localStorage.setItem('showlogin', 1)
              localStorage.setItem('shenfen', 1)
              _this.$alert('注册信息已提交，等待管理人员审核', '提示', {
                confirmButtonText: '确定',
                callback: function () {
                  window.location.href = 'index.html'
                }
              })
            } else {
              _this.$alert(res.msg, '提示', {
                confirmButtonText: '确定',
                callback: function () {
                }
              })
            }
          })
        } else {
          return false
        }
      })
    }
  }
}
</script>
<style lang="less">
    @import "../../assets/css/member";
</style>
<style lang="less" scoped>
    .el-tag + .el-tag {
        margin-left: 10px;
    }

    .button-new-tag {
        margin-left: 10px;
        height: 32px;
        line-height: 30px;
        padding-top: 0;
        padding-bottom: 0;
    }

    .input-new-tag {
        width: 90px;
        margin-left: 10px;
        vertical-align: bottom;
    }
    .uploadimg{
      margin-right: 10px;
      position: relative;
      float: left;
      .mark{
        position:absolute;
        bottom: 25px;
        left: 75px;
      }
    }
    /deep/ .el-input__inner {
        height: 32px !important;

    }
</style>
